<html>
<head><meta charset="utf-8"><title>Disabling cache · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html">Disabling cache</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="207803229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> chabing <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803229">(Aug 24 2020 at 02:50)</a>:</h4>
<p>Can I disable cargo's cache in <code>$CARGO_HOME/registry</code>? I'd rather not have that folder using up gigabytes of space and growing indefinitely. Is there any config.toml option or environment variable that I can set to make all the caching done locally in crates' <code>target</code> directory?</p>



<a name="207803252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803252">(Aug 24 2020 at 02:51)</a>:</h4>
<p>(<a href="http://docs.rs">docs.rs</a> would also be interested in this)</p>



<a name="207803316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803316">(Aug 24 2020 at 02:52)</a>:</h4>
<p>You can change <code>$CARGO_HOME</code> to wherever you want to put it.  You can also use <a href="https://crates.io/crates/cargo-sweep">cargo-sweep</a> to clean up caches.</p>



<a name="207803397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> chabing <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803397">(Aug 24 2020 at 02:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120518">Eric Huss</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/207803316">said</a>:</p>
<blockquote>
<p>You can change <code>$CARGO_HOME</code> to wherever you want to put it.  You can also use <a href="https://crates.io/crates/cargo-sweep">cargo-sweep</a> to clean up caches.</p>
</blockquote>
<p>Right, but changing CARGO_HOME only moves the problem elsewhere. The only solution I can think of is making a symlink from <code>$CARGO_HOME/registry</code> to <code>/tmp/cargo-registry</code>, but that leaves much to be desired (namely that /tmp/cargo-registry has to be manually created because cargo wont create the directory automatically).</p>



<a name="207803477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803477">(Aug 24 2020 at 02:57)</a>:</h4>
<p>I don't fully understand, if you delete the registry directory, you would have to re-download everything whenever you build.</p>



<a name="207803534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803534">(Aug 24 2020 at 02:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120518">Eric Huss</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/207803477">said</a>:</p>
<blockquote>
<p>I don't fully understand, if you delete the registry directory, you would have to re-download everything whenever you build.</p>
</blockquote>
<p>that's better than having registry take up several gigabytes because it grows without bound</p>



<a name="207803539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803539">(Aug 24 2020 at 02:59)</a>:</h4>
<p>(gigabytes is not an exaggeration, <a href="http://docs.rs">docs.rs</a> found this because we ran out of disk space and this was one of the culprits)</p>



<a name="207803597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803597">(Aug 24 2020 at 03:00)</a>:</h4>
<p>cargo sweep is interesting but I'm not super comfortable running stuff like that in prod</p>



<a name="207803608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803608">(Aug 24 2020 at 03:01)</a>:</h4>
<p>the alternative to this is running <code>rm -rf ~/.cargo/registry &amp;&amp; mkdir !$</code> once in a while, which I'm ok with doing, but it would be nice to have it built in</p>



<a name="207803655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> chabing <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803655">(Aug 24 2020 at 03:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120518">Eric Huss</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/207803477">said</a>:</p>
<blockquote>
<p>I don't fully understand, if you delete the registry directory, you would have to re-download everything whenever you build.</p>
</blockquote>
<p>I guess the real problem is that <code>$CARGO_HOME/registry/cache</code> and <code>$CARGO_HOME/registry/src</code> are permanently cached (as opposed to being in crates' target/ directory)</p>



<a name="207803723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803723">(Aug 24 2020 at 03:04)</a>:</h4>
<p>ah, well at the moment, cargo-sweep or deleting the directory are the main options</p>



<a name="207803976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> chabing <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803976">(Aug 24 2020 at 03:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120518">Eric Huss</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/207803723">said</a>:</p>
<blockquote>
<p>ah, well at the moment, cargo-sweep or deleting the directory are the main options</p>
</blockquote>
<p>Is it worth opening an issue to see if <code>registry/src</code> and <code>registry/cache</code> can be moved into <code>target/</code>?</p>



<a name="207803985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207803985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> chabing <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207803985">(Aug 24 2020 at 03:13)</a>:</h4>
<p>(which is not a breaking change since the cargo docs explicitly state that the cache API is not stable)</p>



<a name="207811920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207811920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207811920">(Aug 24 2020 at 06:49)</a>:</h4>
<p>Wouldn't that use <em>more</em> space overall?</p>



<a name="207812392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207812392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207812392">(Aug 24 2020 at 06:58)</a>:</h4>
<p>It would. People mostly ask for the reverse, sharing things between target directories.</p>



<a name="207812472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207812472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207812472">(Aug 24 2020 at 07:00)</a>:</h4>
<p>I think you do want the central directory for <a href="http://docs.rs">docs.rs</a>, it just needs cleaning.</p>



<a name="207812501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207812501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207812501">(Aug 24 2020 at 07:00)</a>:</h4>
<p>If you don't want to use cargo sweep, I would suggest periodically pruning it in some other way (when not in the middle of a build).</p>



<a name="207834677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207834677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207834677">(Aug 24 2020 at 12:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="203546">Laurențiu Nicola</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/207811920">said</a>:</p>
<blockquote>
<p>Wouldn't that use <em>more</em> space overall?</p>
</blockquote>
<p><a href="http://docs.rs">docs.rs</a> cleans target directories after every build, so for us personally it wouldn't.<br>
<span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/207812501">said</a>:</p>
<blockquote>
<p>If you don't want to use cargo sweep, I would suggest periodically pruning it in some other way (when not in the middle of a build).</p>
</blockquote>
<p>that's probably more effective so we get most of the caching benefits. We need to work out synchronization for builds though <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span> <a href="https://github.com/rust-lang/docs.rs/issues/984">https://github.com/rust-lang/docs.rs/issues/984</a></p>



<a name="207840204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207840204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matthiaskrgr <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207840204">(Aug 24 2020 at 13:06)</a>:</h4>
<p>you can use cargo-cache to clean up the $CARGO_HOME <br>
<a href="https://crates.io/crates/cargo-cache">https://crates.io/crates/cargo-cache</a></p>



<a name="207847355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207847355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207847355">(Aug 24 2020 at 14:09)</a>:</h4>
<p>Ah, apologies, I got sweep and cache mixed up.</p>



<a name="207877504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207877504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> chabing <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207877504">(Aug 24 2020 at 18:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="203546">Laurențiu Nicola</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/207811920">said</a>:</p>
<blockquote>
<p>Wouldn't that use <em>more</em> space overall?</p>
</blockquote>
<p>It <em>could</em>. but I think it would still be a better trade-off. The problem with putting it in $CARGO_HOME is that it grows without bound. Having it in <code>target/</code> would at least make a correlation between disk usage an the # of projects being developed. When I'm done working on a project, I delete that directory until I come back to the project. I wouldn't expect build artifacts to stick around anywhere after that. <code>cargo install</code> also suffers from this: installing a binary (which doesn't ever need the source/cache of its dependencies after installation) permanently leaves stuff in $CARGO_HOME</p>



<a name="207878114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207878114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207878114">(Aug 24 2020 at 18:23)</a>:</h4>
<p>updating a <code>cargo install</code> is sometimes well served by keeping the sources and cache files, though i do take your point</p>



<a name="207878178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207878178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207878178">(Aug 24 2020 at 18:24)</a>:</h4>
<p>It seems like the standard tradeoff: do you want to cache things, vs do you want to recompute/redownload things.</p>



<a name="207878556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207878556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207878556">(Aug 24 2020 at 18:27)</a>:</h4>
<p>I'd propose that the solution here is for cargo to remind the user of the size of their cached stuff (perhaps after <code>cargo install</code> when it's already printing other "global" updates about new bins), and then to also move a plugin for clearing the cache into the main cargo distribution (like how <code>cargo tree</code> became an official plugin), so that users can act on the size of the cache if they choose to.</p>



<a name="207881465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207881465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> chabing <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207881465">(Aug 24 2020 at 18:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/207878556">said</a>:</p>
<blockquote>
<p>I'd propose that the solution here is for cargo to remind the user of the size of their cached stuff (perhaps after <code>cargo install</code> when it's already printing other "global" updates about new bins), and then to also move a plugin for clearing the cache into the main cargo distribution (like how <code>cargo tree</code> became an official plugin), so that users can act on the size of the cache if they choose to.</p>
</blockquote>
<p>Another possible solution is to add a setting to config.toml that would put the cache in <code>target/</code></p>



<a name="207881588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207881588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207881588">(Aug 24 2020 at 18:50)</a>:</h4>
<p>It'd be nice for that to be fine-grained. For instance, put downloaded crate files into a shared location, and git dependencies into a private one (less likely to be reused), and unpacked sources into a private one (can always be re-unpacked).</p>



<a name="207892877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207892877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207892877">(Aug 24 2020 at 20:25)</a>:</h4>
<p><code>ccache</code> and <code>SCons</code> (at least) support configuring limits for cache sizes, then they evict items from the cache using something like LRU when the limit is exceeded.<br>
Perhaps <code>cargo</code> could use something like this as well.</p>



<a name="207906797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/207906797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#207906797">(Aug 24 2020 at 22:54)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> That seems reasonable, assuming there's a reliable concept of "used" that Cargo can use. Cargo could track that, easily enough.</p>



<a name="208162750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/208162750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> chabing <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#208162750">(Aug 26 2020 at 23:34)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/207906797">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> That seems reasonable, assuming there's a reliable concept of "used" that Cargo can use. Cargo could track that, easily enough.</p>
</blockquote>
<p>What needs to be done to get this to happen? An RFC? GitHub issue?</p>



<a name="208164111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/208164111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#208164111">(Aug 26 2020 at 23:54)</a>:</h4>
<p>There's already several issues about this (such as <a href="https://github.com/rust-lang/cargo/issues/7150">https://github.com/rust-lang/cargo/issues/7150</a> and <a href="https://github.com/rust-lang/cargo/pull/6477">https://github.com/rust-lang/cargo/pull/6477</a> and <a href="https://github.com/rust-lang/cargo/issues/3289">https://github.com/rust-lang/cargo/issues/3289</a>).  The main problem is reliably tracking last-use information.  Different parts of cargo's cache may need different solutions.  I'm thinking there may need to be some kind of files to track last-use information to help with cache eviction. Something like the index cache may need a different solution (it currently creates lots of little files, which isn't exactly ideal) than the <code>.crate</code> cache.  I've toyed with sqlite, but I'm not really confident that is the best route.  There are several constraints to consider, like performance, different filesystems, clock and timestamp issues, locking and concurrency issues, Docker caching, etc. Unfortunately I don't have much time to help.  I'm not sure how to suggest moving forward. Perhaps putting something RFC-like that would sketch out the solution? Would help to have done some prototyping to explore issues like performance (and comparing and contrasting to cargo-cache and cargo-sweep).  I unfortunately can't promise much in terms  of helping with it.</p>



<a name="208166873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/208166873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#208166873">(Aug 27 2020 at 00:36)</a>:</h4>
<p>btw, I also don't want to imply that embedding something like cargo-cache as-is isn't out of the picture, I just haven't looked at it too closely.</p>



<a name="208288581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/208288581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matthiaskrgr <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#208288581">(Aug 27 2020 at 23:26)</a>:</h4>
<p>Hmm, adding a subcommand to <code>cargo-cache</code> that removes older files until the cache is within a certain size limit again does not sound too difficult with what I've got already...</p>



<a name="208288716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/208288716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matthiaskrgr <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#208288716">(Aug 27 2020 at 23:29)</a>:</h4>
<p>It's just that cargo won't be able to trigger an automatic cleanup by cargo-cache somehow; the user still has to trigger it (or automatically call cargo-cache after each <code>cargo</code>invocation  via some shell alias or whatever... :/</p>



<a name="208300552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/208300552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#208300552">(Aug 28 2020 at 03:02)</a>:</h4>
<p>i think if there's some way to make <code>rustup update</code> optionally also clear cache that would be best</p>



<a name="208312287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Disabling%20cache/near/208312287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Silverstone <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Disabling.20cache.html#208312287">(Aug 28 2020 at 07:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/246057-t-cargo/topic/Disabling.20cache/near/208300552">said</a>:</p>
<blockquote>
<p>i think if there's some way to make <code>rustup update</code> optionally also clear cache that would be best</p>
</blockquote>
<p>That's an interesting idea.  I wonder if it would be sufficient to add support to <code>rustup</code> to have a post-update shell command configurable via our settings file.  That way if you wanted that you could configure it to run <code>cargo cache-cleanup</code> or whatever command is appropriate.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>